#include<stdio.h>
#include<stdlib.h>

int k;
void quick_sort(int a[],int n, int left, int right)
{
    if(left >= right)
    {
        return;
    }
    int i = left;
    int j = right;
    int t = rand() % (right - left + 1);
    t = t + left;
    int tmp = a[t];
    a[t] = a[i];
    a[i] = tmp;
    while(i < j)
    {
        while(a[j] >= tmp && i < j)
        {
            j--;
        }
        a[i] = a[j];
        while(a[i] <= tmp && i < j)
        {
            i++;
        }
        a[j] = a[i];
    }
    a[i] = tmp;
    if(i==k)
    {
        printf("%d",a[k]);
        exit(0);
    }
    else if(i>k)
    {
        quick_sort(a,n, left, i - 1);
    }
    else
    {
        quick_sort(a,n, i + 1, right);
    }

}

int main()
{
    int n;
    scanf("%d%d", &n,&k);
    int a[n];
    k--;
    for(int i = 0; i <n; i++)
    {
        scanf("%d", &a[i]);
    }

    quick_sort(a,n,0,n-1);
    printf("%d",a[k]);
    return 0;
}

